<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 200px;
            height: 200px;
            border: 1px solid #ccc;
        }
    </style>
</head>

<body>
    <div id="app">
        <div>
            <span>R：</span>
            <input type="text" v-model.number="r">
        </div>
        <div>
            <span>G：</span>
            <input type="text" v-model.number="g">
        </div>
        <div>
            <span>B：</span>
            <input type="text" v-model.number="b">
        </div>
        <hr>
        <div class="box" :style="{ backgroundColor: rgb }">
            {{ rgb }}
        </div>
        <button @click="show">按钮</button>
    </div>

    <script src="./lib/vue-2.6.12.js"></script>
    <script src="./lib/axios.js"></script>
    <script src="./lib/jquery-v3.6.0.js"></script>
    <script>
        const mv = new Vue({
            el: '#app',
            data: {
                r: 0,
                g: 0,
                b: 0,
            },
            methods: {
                show() {
                    console.log(this.rgb);
                }
            },
            // 所有的计算属性都要定义到computed节点下面
            computed: {
                rgb() {
                    return `rgb(${this.r}, ${this.g}, ${this.b})`;
                }
            }

        })
    </script>
</body>

</html>